package com.wwy.hkapi.controller;

import com.wwy.hkapi.HKApi.HkLogin;
import com.wwy.hkapi.HKApi.HkRealPlay;
import com.wwy.hkapi.HKApi.UserInfo;
import com.wwy.hkapi.domain.PreviewEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: wwy
 * @Date: 2022/6/14 14:53
 */
@RestController
@RequestMapping("/hkApi")
public class HkDemoController {
    /**
     * 预览
     * @param previewEntity
     * @return
     */
    @PostMapping("/preview")
    public Map<String,Object> preview(@RequestBody PreviewEntity previewEntity ){
        //登录
        UserInfo userInfo = new UserInfo();
        userInfo.setIp(previewEntity.getIp());
        userInfo.setUsername(previewEntity.getUserName());
        userInfo.setPassword(previewEntity.getPassword());
        userInfo.setPort(8000);
        int login = HkLogin.getUserId(userInfo);
        if(login<=-1){
            //登录失败
            return new HashMap<>();
        }
        HkRealPlay hkRealPlay = new HkRealPlay();
        hkRealPlay.preview(login,previewEntity.getChannel(),previewEntity.getStreamType());
        return new HashMap<>();
    }

}
